Given a binary string s
and a positive integer n
, return true
if the binary representation of all the integers in the range[1, n]
are substrings ofs
, orfalse
otherwise.
A substring is a contiguous sequence of characters within a string.
Input: s = "0110", n = 3 Output: true
Input: s = "0110", n = 4 Output: false
1 <= s.length <= 1000
s[i]
is either'0'
or'1'
.1 <= n <= 109
implSolution{pubfnquery_string(s:String,n:i32) -> bool{for x in1..=n {if !s.contains(&format!("{:b}", x)){returnfalse;}}true}}